package com.renren.project.db.utils.bean;

/**
 * @since 2020/11/7 10:41
 */
public class StringBean {

    public String up(String input) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (i == 0 || input.charAt(i - 1) == '_') {
                sb.append(String.valueOf(c).toUpperCase());
            } else if (c != '_') {
                sb.append(c);
            }
        }
        return sb.toString();
    }

    public String firstLowUp(String input) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (i != 0 && input.charAt(i - 1) == '_') {
                sb.append(String.valueOf(c).toUpperCase());
            } else if (c != '_') {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}
